<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>
<style>

</style>

<body>
    <header class="aui-bar aui-bar-nav" style="position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            维修中
        </div>
        <!-- <div class="aui-bar-tab-item" style="float:right;margin:auto 15px auto auto" tapmode id="scan" onclick="doScan()">
            <i class="aui-iconfont aui-icon-scan" style="font-size: 1.8rem;"></i>
        </div> -->
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="aui-searchbar" id="search" style="position: relative;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-input-addon aui-iconfont aui-icon-scan " style="font-size: 1.6rem"
                    onclick="doScan('equipCode');"></i>
                <div class="aui-searchbar-input">
                    <form>

                        <input type="search" placeholder="请输入设备编码" id="equipCode">
                    </form>
                </div>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4"
                onclick="doSearch()">搜索</div>
        </div>
        <!-- <div class="aui-row ui-selectee">
            <div class="aui-col-xs-4 sortable column ui-sortable">
                <select class="ui-selectee">
              <option value="" class="ui-selectee" style="text-align:center;">状态</option>
            </select>
            </div>
            <div class="aui-col-xs-4 sortable column ui-sortable">
                <select class="ui-selectee">
              <option value="" class="ui-selectee">故障等级</option>
            </select>
            </div>
            <div class="aui-col-xs-4 sortable column ui-sortable">
                <select class="ui-selectee">
              <option value="" class="ui-selectee">全部</option>
            </select>
            </div>
        </div> -->

        <input style="font-size: 16px; text-align: center;" type="text" readonly id="eqNum" value="" />
        <ul class="ui-selectee" id="tbodyHtml">

        </ul>

    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var equipCode = ""; //设备编码
    //初始化
    apiready = function () {
        $("#equipCode").focus();
        idSelector = "equipCode";
        doSearch();
    }
    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }
    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {
            //alert(ret);扫码的结果都是编码
            //1：设备编码
            if (idSelector == 'equipCode') {

                $("#equipCode").val(ret);
                //查询仓库
                //getWorkCenter(ret, idSelector);
            }
        });
    }


    //查询
    function doSearch() {
        //设备编码
        var equipCode = $("#equipCode").val();

        if (equipCode != null && equipCode != undefined && equipCode != "") {
            equipCode = equipCode.trim();
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getEquipmentFaultList";
        var data = {
            values: {
                equipCode: equipCode,
                un: un,
                // status: '3'
                status:'1'
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 30,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    var html = "";
                    for (var i = 0; i < list.length; i++) {
                        if(list[i].ext28==null||list[i].ext28=='null' ){
                            list[i].ext28 = ''
                        }
                        html += "<li class='sortable ui-selectee ui-sortable'>";
                        html += "<ul class='aui-list aui-media-list ui-selectee'>";
                        html += "<li class='aui-list-item  ui-selectee'>";
                        html += "<div class='aui-media-list-item-inner ui-selectee'>";
                        html += "<div class='aui-list-item-inner ui-selectee'>";
                        html += "<div class='aui-list-item-text ui-selectee' >";
                        html += "<div class='aui-list-item-title ui-selectee' '>" + list[i].equipName + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='color: blue;'>" + '已故障 ' + list[i].faultTimeDifference + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>维修单号</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-top:4px;'>" + list[i].faultOrderNo + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>设备编码</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-top:4px;'>" + list[i].equipCode + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>紧急程度</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-top:4px;'>" + list[i].ext16 + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>故障描述</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-top:4px;'>" + list[i].description + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>维修状态</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-top:4px;'>" + list[i].ext28 + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'>维修人</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-top:4px;'>" + list[i].ydPerson + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee' style='height: 25px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title'> <i class='aui-iconfont aui-icon-location'></i></div>";
                        html += "<div class='aui-list-item-inner ui-selectee' style='margin-top:4px;'>" + list[i].ext09 + "</div>";
                        html += "</div>";

                        html += "<div class='aui-list-item-text ui-selectee'>";
                        html += "<div class='aui-list-item-label ui-selectee'>" + "</div>";
                        html += "<div class='aui-list-item-right aui-btn ui-selectee' style='background:#29B4AD;color:#f5f5f5;' onclick='goPageDetail(\"" + list[i].sysid + "\");'>" + '进入任务' + "</div>";
                        html += "</div>";
                        html += "</div>";
                        html += "</div>";
                        html += "</li>";
                        html += "</ul>";
                        html += "</li>";
                    }
                    //console.log(html);
                    $api.html($api.byId("tbodyHtml"), html);

                    $("#eqNum").val('设备故障('+list.length+')');
                    //失败
                } else if (myobj.code == "1") {
                    //清空表格数据
                    $api.html($api.byId("tbodyHtml"), "");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //订单返回按钮
    function closeWin() {
        api.closeWin({});
    }

    //跳转详情页面
    function goPageDetail(sysid) {
        //打开页面
        api.openWin({
            name: 'emequipmentfaltRepaire',
            url: 'emequipmentfaltRepaire' + '.html',
            pageParam: {
                sysid: sysid
                
            },
        });
    }
</script>

</html>